home *** CD-ROM | disk | FTP | other *** search
Wrap
<!-- #include file="i_utils.asp" --> <% check_security(2) %> <% dim Ratings dim LinkID dim CatID dim DateAdded dim LinkTypeID dim Title dim URL dim DownloadURL dim DownloadFee dim Description dim Email dim Priority dim Impressions dim ClickThrus dim AvgRating dim Display dim edit_links_sql dim Cat dim Site dim Send dim view_links_sql sub request_edit_links ''' request expected input parameters for this form Ratings = request("Ratings") LinkID = request("LinkID") CatID = request("CatID") DateAdded = request("DateAdded") LinkTypeID = request("LinkTypeID") Title = request("Title") URL = request("URL") DownloadURL = request("DownloadURL") DownloadFee = request("DownloadFee") Description = request("Description") Email = request("Email") Priority = request("Priority") Impressions = request("Impressions") ClickThrus = request("ClickThrus") AvgRating = request("AvgRating") Display = request("Display") end sub sub request_view_links ''' request expected input parameters for this form Email = request("Email") LinkID = request("LinkID") URL = request("URL") Display = request("Display") Title = request("Title") Cat = request("Cat") Site = request("Site") Send = request("Send") Description = request("Description") DateAdded = request("DateAdded") Priority = request("Priority") AvgRating = request("AvgRating") ClickThrus = request("ClickThrus") Impressions = request("Impressions") end sub sub validate_edit_links ''' request and validate data entered from this form Ratings = trim(request("Ratings")) LinkID = trim(request("LinkID")) CatID = trim(request("CatID")) if CatID = "" then error_list.add "484444","Category must be specified." b_error = true end if DateAdded = trim(request("DateAdded")) if DateAdded <> "" AND (not isdate(DateAdded)) then error_list.add "484446date","Added must be a valid date (MM/DD/YY)." b_error = true end if LinkTypeID = trim(request("LinkTypeID")) if LinkTypeID = "" then error_list.add "484453","Link Type <A href='admin_linktypes.asp'>?</A> must be specified." b_error = true end if Title = trim(request("Title")) if Title = "" then error_list.add "484456","Title must be specified." b_error = true end if URL = trim(request("URL")) if URL = "" then error_list.add "484457","URL must be specified." b_error = true end if DownloadURL = trim(request("DownloadURL")) DownloadFee = trim(request("DownloadFee")) Description = trim(request("Description")) Email = trim(request("Email")) Priority = trim(request("Priority")) Impressions = trim(request("Impressions")) ClickThrus = trim(request("ClickThrus")) AvgRating = trim(request("AvgRating")) Display = trim(request("Display")) end sub sub validate_view_links ''' request and validate data entered from this form Email = trim(request("Email")) LinkID = trim(request("LinkID")) URL = trim(request("URL")) Display = trim(request("Display")) Title = trim(request("Title")) Cat = trim(request("Cat")) Site = trim(request("Site")) Send = trim(request("Send")) Description = trim(request("Description")) DateAdded = trim(request("DateAdded")) if DateAdded <> "" AND (not isdate(DateAdded)) then error_list.add "484462date","Added must be a valid date (MM/DD/YY)." b_error = true end if Priority = trim(request("Priority")) AvgRating = trim(request("AvgRating")) ClickThrus = trim(request("ClickThrus")) Impressions = trim(request("Impressions")) end sub sub get_defaults_edit_links ''' set default values for this form Ratings = 1 DateAdded = "" & now() & "" end sub sub get_defaults_view_links ''' set default values for this form Display = 1 end sub sub db_select_edit_Links sql = "SELECT " & _ "Ratings, " & _ "LinkID, " & _ "CatID, " & _ "DateAdded, " & _ "LinkTypeID, " & _ "Title, " & _ "URL, " & _ "DownloadURL, " & _ "DownloadFee, " & _ "Description, " & _ "Email, " & _ "Priority, " & _ "Impressions, " & _ "ClickThrus, " & _ "AvgRating, " & _ "Display FROM Links" & _ " WHERE " & _ "Links.LinkID = " & to_sql(LinkID,"number") & "" on error resume next set rs = cn.Execute(sql) if err.number <> 0 then b_error = true error_list.add "select_data_edit_Links", "The data selection failed. " & err.description elseif rs.EOF then b_results = false msg_list.add "select_data_edit_Links", "The record was removed from the database." else Ratings = rs("Ratings") LinkID = rs("LinkID") CatID = rs("CatID") DateAdded = rs("DateAdded") LinkTypeID = rs("LinkTypeID") Title = rs("Title") URL = rs("URL") DownloadURL = rs("DownloadURL") DownloadFee = rs("DownloadFee") Description = rs("Description") Email = rs("Email") Priority = rs("Priority") Impressions = rs("Impressions") ClickThrus = rs("ClickThrus") AvgRating = rs("AvgRating") Display = rs("Display") end if rs.Close on error goto 0 end sub sub db_insert_edit_Links sql = "INSERT INTO Links" & _ "(" & _ "Ratings," & _ "CatID," & _ "DateAdded," & _ "LinkTypeID," & _ "Title," & _ "URL," & _ "DownloadURL," & _ "DownloadFee," & _ "Description," & _ "Email," & _ "Priority," & _ "Impressions," & _ "ClickThrus," & _ "AvgRating," & _ "Display" & _ ") VALUES (" & to_sql(Ratings,"number") & "," & _ "" & to_sql(CatID,"number") & "," & _ "" & to_sql(DateAdded,"text") & "," & _ "" & to_sql(LinkTypeID,"number") & "," & _ "" & to_sql(Title,"text") & "," & _ "" & to_sql(URL,"text") & "," & _ "" & to_sql(DownloadURL,"text") & "," & _ "" & to_sql(DownloadFee,"text") & "," & _ "" & to_sql(Description,"text") & "," & _ "" & to_sql(Email,"text") & "," & _ "" & to_sql(Priority,"number") & "," & _ "" & to_sql(Impressions,"number") & "," & _ "" & to_sql(ClickThrus,"number") & "," & _ "" & to_sql(AvgRating,"text") & "," & _ "" & to_sql(Display,"number") & ")" & _ "" 'response.write sql on error resume next cn.Execute(sql) if err.Number <> 0 then b_error = true error_list.add "db_insert_edit_Links" & err.Number ,"The database insert failed. " & err.Description else set rs = cn.Execute("SELECT @@IDENTITY") LinkID = rs(0) rs.Close msg_list.add "db_insert_edit_Links","The database insert was successful." end if on error goto 0 end sub sub db_update_edit_Links sql = "UPDATE Links SET " & _ "Ratings = " & to_sql(Ratings,"number") & ", " & _ "CatID = " & to_sql(CatID,"number") & ", " & _ "DateAdded = " & to_sql(DateAdded,"text") & ", " & _ "LinkTypeID = " & to_sql(LinkTypeID,"number") & ", " & _ "Title = " & to_sql(Title,"text") & ", " & _ "URL = " & to_sql(URL,"text") & ", " & _ "DownloadURL = " & to_sql(DownloadURL,"text") & ", " & _ "DownloadFee = " & to_sql(DownloadFee,"text") & ", " & _ "Description = " & to_sql(Description,"text") & ", " & _ "Email = " & to_sql(Email,"text") & ", " & _ "Priority = " & to_sql(Priority,"number") & ", " & _ "Impressions = " & to_sql(Impressions,"number") & ", " & _ "ClickThrus = " & to_sql(ClickThrus,"number") & ", " & _ "AvgRating = " & to_sql(AvgRating,"text") & ", " & _ "Display = " & to_sql(Display,"number") & " WHERE " & _ "LinkID = " & to_sql(LinkID,"number") & "" 'response.write sql on error resume next cn.execute(sql) if err.number <> 0 then b_error = true error_list.add "db_update_edit_Links" & err.Number ,"The database update failed. " & err.Description else msg_list.add "db_update_edit_Links" & LinkID,"The database update was successful." end if on error goto 0 end sub sub db_delete_edit_Links sql = "DELETE FROM Links" & _ " WHERE " & _ "LinkID = " & to_sql(LinkID,"number") & "" 'response.write sql on error resume next cn.Execute(sql) if err.number <> 0 then b_error = true error_list.add "db_delete_edit_Links" & err.Number ,"The database deletion failed. " & err.Description else msg_list.add "db_delete_edit_Links","The record was removed." end if on error goto 0 end sub sub db_select_view_Links view_Links_sql = "SELECT " & _ "AvgRating, " & _ "Cat, " & _ "ClickThrus, " & _ "Links.Description AS Description, " & _ "DownloadURL, " & _ "Email, " & _ "DateAdded, " & _ "Impressions, " & _ "LinkID, " & _ "LinkType, " & _ "Priority, " & _ "Ratings, " & _ "Title, " & _ "Display," & _ "URL FROM Cats, Links, LinkTypes WHERE Cats.CatID=Links.CatID AND Links.LinkTypeID=LinkTypes.LinkTypeID" if request("sortby") <> "" AND inStr(lcase(view_Links_sql),"order by") = 0 then view_Links_sql = view_Links_sql + " ORDER BY " & request("sortby") end sub sub db_update_view_Links sql = "UPDATE Links SET Display = " & to_sql(Display,"number") & " WHERE LinkID = " & LinkID & "" 'response.write sql on error resume next cn.execute(sql) if err.number <> 0 then b_error = true error_list.add "db_update_view_Links" & err.Number ,"The database update failed. " & err.Description else msg_list.add "db_update_view_Links" & LinkID,"The database update was successful." end if on error goto 0 end sub sub db_delete_view_Links sql = "DELETE FROM Links" & _ " WHERE " & _ "LinkID = " & to_sql(LinkID,"number") & "" 'response.write sql on error resume next cn.Execute(sql) if err.number <> 0 then b_error = true error_list.add "db_delete_view_Links" & err.Number ,"The database deletion failed. " & err.Description else msg_list.add "db_delete_view_Links","The record was removed." end if on error goto 0 end sub do_search = request("do_search") ''' request form keys LinkID = request("LinkID") ''' request action action = lcase(request("action")) ''' action case handler select case action case "select_edit_links" ' select the requested key record from database if LinkID <> "" then db_select_edit_Links else b_error = true error_list.add "edit_edit_Links", "Specify record to select." end if case "insert_edit_links" ' request form data and insert a new record into database validate_edit_links if not b_error then db_insert_edit_links end if case "update_edit_links" ' request form data and update an existing database record validate_edit_links if not b_error then if LinkID <> "" then db_update_edit_links else b_error = true error_list.add "update_edit_links", "Specify record to update." end if end if case "delete_edit_links" ' delete the requested key database record if LinkID <> "" then db_delete_edit_links response.redirect request.servervariables("script_name") & "?msg=The+record+was+deleted." else b_error = true error_list.add "delete_edit_links", "Specify record to delete." end if case "update_view_links"' request form data from edit grid to update existing database records ' this case is only created when a grid form's 'update' property is enabled for i = 1 to request.form("LinkID").count Email = trim(request("Email")(i)) LinkID = trim(request("LinkID")(i)) URL = trim(request("URL")(i)) Display = trim(request("Display_" & i & "")) db_update_view_links next response.redirect request.servervariables("script_name") & "?msg=The+database+was+updated." case "delete_view_links"' request form data from edit grid to delete existing database records ' this case is only created when a grid form's 'update' property is enabled if LinkID <> "" then db_delete_view_links response.redirect request.servervariables("script_name") & "?msg=The+record+was+deleted." else b_error = true error_list.add "delete_view_links", "Specify record to delete." end if end select ' no action was specified, so handle the default case(s) if LinkID <> "" then db_select_edit_links end if db_select_view_links %> <!-- #include file='i_header.asp' --> <!-- #include file='i_menu.asp' --> <!-- #include file="i_menu_admin.asp" --> <% display_errs display_msg %> <table class='headerTable'> <tr> <td class='headerTD'> <A href='admin_links.asp'>Link Manager</A> </td> </tr> </table> <table > <form name="edit_Links" action="admin_links.asp" method="post" > <input type=hidden name="Ratings" value="<% =Ratings %>"> <input type=hidden name="LinkID" value="<% =LinkID %>"> <tr> <td class='labelTD'>Category</td> <td class='dataTD' > <select name="CatID" > <option></option> <% =get_options ("SELECT Cats3.CatId, Cats.Cat, Cats1.Cat, Cats2.Cat, Cats3.Cat FROM (((Cats As Cats3 left JOIN Cats As Cats2 ON Cats3.ParentId = Cats2.CatId) left JOIN Cats As Cats1 ON Cats2.ParentId = Cats1.CatId) LEFT JOIN Cats As Cats ON Cats1.ParentId = Cats.CatId) WHERE Cats.ParentId is NULL order by (Cats.Cat & Cats1.Cat & Cats2.Cat & Cats3.Cat)", CatID) %> </select> </td> <td class='labelTD'>select the best category for this resource</td> </tr> <input type=hidden name="DateAdded" value="<% =DateAdded %>"> <tr> <td class='labelTD'>Link Type <A href='admin_linktypes.asp'>?</A></td> <td class='dataTD' > <select name="LinkTypeID" > <option></option> <% =get_options ("SELECT LinkTypeID, LinkType FROM LinkTypes", LinkTypeID) %> </select> </td> <td class='labelTD'>select the type of resource</td> </tr> <tr> <td class='labelTD'>Title</td> <td class='dataTD' > <input type=text name="Title" size="" maxlength="60" value="<% =Title%>"> </td> <td class='labelTD'>enter a title (upto 60 characters)</td> </tr> <tr> <td class='labelTD'>URL</td> <td class='dataTD' > <input type=text name="URL" size="" maxlength="120" value="<% =URL%>"> </td> <td class='labelTD'>specify the URL, including http://, for the resource</td> </tr> <tr> <td class='labelTD'>Download URL</td> <td class='dataTD' > <input type=text name="DownloadURL" size="" maxlength="120" value="<% =DownloadURL%>"> </td> <td class='labelTD'>specify the download URL if any</td> </tr> <tr> <td class='labelTD'>Minumum Cost (if any)</td> <td class='dataTD' > <input type=text name="DownloadFee" size="" maxlength="" value="<% =DownloadFee%>"> </td> <td class='labelTD'></td> </tr> <tr> <td class='labelTD'>Description</td> <td class='dataTD' > <textarea name="Description" rows='10' cols='60'><% =to_html(Description) %></textarea> </td> <td class='labelTD'>enter a description for this resource (upto 1000 characters). This can include HTML code.</td> </tr> <tr> <td class='labelTD'>Webmaster Email</td> <td class='dataTD' > <input type=text name="Email" size="" maxlength="" value="<% =Email%>"> </td> <td class='labelTD'></td> </tr> <tr> <td class='labelTD'>Priority</td> <td class='dataTD' > <% if not isnull(Priority) then if (Priority < 1) AND (not Priority) then Priority = 0 else Priority = 0 end if %> <select name="Priority" > <option></option> <option <% if "3" = cStr(Priority) then %>selected<% end if %> value="3">low</option> <option <% if "2" = cStr(Priority) then %>selected<% end if %> value="2">med</option> <option <% if "1" = cStr(Priority) then %>selected<% end if %> value="1">high</option> </select> </td> <td class='labelTD'>select a priority -- used for ranking display in results list</td> </tr> <tr> <td class='labelTD'>Impressions</td> <td class='dataTD' > <input type=text name="Impressions" size="" maxlength="" value="<% =Impressions%>"> </td> <td class='labelTD'># of times the resource has been viewed</td> </tr> <tr> <td class='labelTD'>Clickthrus</td> <td class='dataTD' > <input type=text name="ClickThrus" size="" maxlength="" value="<% =ClickThrus%>"> </td> <td class='labelTD'># of times the related URL has been visited</td> </tr> <tr> <td class='labelTD'>Your Rating</td> <td class='dataTD' > <% if isnull(AvgRating) then AvgRating = "" %> <select name="AvgRating" > <option <% if "1" = cStr(AvgRating) then %>selected<% end if %>>1</option> <option <% if "2" = cStr(AvgRating) then %>selected<% end if %>>2</option> <option <% if "3" = cStr(AvgRating) then %>selected<% end if %>>3</option> <option <% if "4" = cStr(AvgRating) then %>selected<% end if %>>4</option> <option <% if "5" = cStr(AvgRating) then %>selected<% end if %>>5</option> <option <% if "6" = cStr(AvgRating) then %>selected<% end if %>>6</option> <option <% if "7" = cStr(AvgRating) then %>selected<% end if %>>7</option> <option <% if "8" = cStr(AvgRating) then %>selected<% end if %>>8</option> <option <% if "9" = cStr(AvgRating) then %>selected<% end if %>>9</option> <option <% if "10" = cStr(AvgRating) then %>selected<% end if %>>10</option> </select> </td> <td class='labelTD'>Select your 1(low) to 10(high) rating for this link.</td> </tr> <tr> <td class='labelTD'>Display</td> <td class='dataTD' > <% if Display = "" then Display = false %> <input type=checkbox <% if Display then %>checked<% end if %> name="Display" value="1"> </td> <td class='labelTD'>check box to approve this link for display</td> </tr> <tr> <td class=labelTD align=right> <% if LinkID <> "" then %><input type=button name=new_button value='NEW LINK' onclick="window.location = '<% =request.servervariables("script_name") %>'"><% end if %> </td> <td class=dataTD> <% if LinkID = "" then %><input type=submit name=insert_button value='ADD LINK'><% end if %> <% if LinkID <> "" then %><input type=submit name=update_button value='UPDATE'><% end if %> <% if LinkID <> "" then %><input type=submit name=delete_button value='DELETE' onclick="document.edit_Links.action.value = 'delete_edit_Links'"><% end if %> </td> <td class=labelTD> </td> <input type=hidden name="action" value="<% if LinkID <> "" then %>update<% else %>insert<%end if %>_edit_Links"></tr> </form> </table> <% page_no = request("page_no") if page_no = "" then page_no = 1 if view_Links_sql <> "" then cmd.CommandText = view_Links_sql rs.Filter = "" rs.CursorLocation = 3 rs.CacheSize = 5 rs.Open cmd if not rs.EOF then rs.MoveFirst rs.PageSize = 50 max_count = cInt(rs.PageCount) num_recs = rs.RecordCount rs.AbsolutePage = page_no results = true else results = false rs.Close end if else results = false end if rec_count = 0 %> <% if results = true then %> <table > <form name="view_Links" action="admin_links.asp" method="post" > <tr> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Display" class=fieldFont title="">Approved</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Title" class=fieldFont title="">Title</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Cat" class=fieldFont title="">Category</a></td> <td class='fieldTD'>Site</td> <td class='fieldTD'>Email</td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Description" class=fieldFont title="">Description</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=DateAdded" class=fieldFont title="">Added</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Priority" class=fieldFont title="">Priority</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=AvgRating" class=fieldFont title="">Rating</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=ClickThrus" class=fieldFont title="">Clicks</a></td> <td class='fieldTD'><a href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no %>&sortby=Impressions" class=fieldFont title="">Views</a></td> </tr> <% do while not rs.EOF AND (rec_count < rs.Pagesize) ':: read db record on error resume next Email = rs("Email") LinkID = rs("LinkID") URL = rs("URL") Display = rs("Display") Title = rs("Title") Cat = rs("Cat") Site = rs("Site") Send = rs("Send") Description = rs("Description") DateAdded = rs("DateAdded") Priority = rs("Priority") AvgRating = rs("AvgRating") ClickThrus = rs("ClickThrus") Impressions = rs("Impressions") on error goto 0 %> <input type=hidden name="Email" value="<% =Email %>"> <input type=hidden name="LinkID" value="<% =LinkID %>"> <input type=hidden name="URL" value="<% =URL %>"> <tr> <td class='dataTD' > <input type=checkbox <% if Display then %>checked<% end if %> name="Display_<% =rec_count+1 %>" value="<% =1 %>"> </td> <td class='dataTD' > <a href="admin_links.asp?LinkId=<% =LinkId %>"><% =Title %></a> </td> <td class='dataTD' > <% =Cat %> </td> <td class='dataTD' > <A href="<% =url %>" target="site_win">[launch]</A><% =Site %> </td> <td class='dataTD' > <% if Email <> "" then %><A href="mailto:<% =email %>">[send]</A><% end if %><% =Send %> </td> <td class='dataTD' > <% if description <> "" then description = left(server.htmlencode(description),40) %><% =Description %>... </td> <td class='dataTD' nowrap> <% =DateAdded %> </td> <td class='dataTD' > <% =Priority %> </td> <td class='dataTD' > <% =AvgRating %> </td> <td class='dataTD' > <% =ClickThrus %> </td> <td class='dataTD' > <% =Impressions %> </td> </tr> <% rs.MoveNext rec_count = rec_count + 1 loop rs.Close %> <tr class=formtr> <td class=dataTD align=right colspan=14> <input type=submit name=update_button value=update> </td> </tr> <input type=hidden name="action" value="update_view_links"> </form> </table> <% else %> <% end if %> <% if max_count > 1 then %> <!-- paging footer --> <TABLE class=HeaderTable > <tr> <td width="20%" class=HeaderTD> <% if page_no > 1 then %> <a class=HeaderFont href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no-1 %>&sortby=<% =request("sortby") %>">PREV</a> <% else %> <% end if %> </td> <td align=center class=HeaderTD> Page <% for i = 1 to max_count %> <% if i = cint(page_no) then %> <b><%=i%></b> <% else %> <a class=HeaderFont href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =i %>&sortby=<% =request("sortby") %>"><%=i%></a> <% end if %> <%next %> </td> <td align=right width="20%" class=HeaderTD> <% if cInt(page_no) < cInt(max_count) then %> <a class=HeaderFont href="<% =request.servervariables("script_name") %>?<% =request_string %>page_no=<% =page_no+1 %>&sortby=<% =request("sortby") %>">NEXT</a> <% end if %> </td> </tr> </TABLE> <% end if %> <!-- #include file=i_footer.asp --> <% ':: assure that any db resources are freed on error resume next rs.Close set rs = NOTHING cn.Close set cn = NOTHING user_cn.Close set user_cn = NOTHING on error goto 0 %>